<template>
  <div>
    <div class="fixHead">
      <div class="title">
        <span class="iconfont icon-jiantou" @click="$router.go(-1)"></span>
        <span class="icon-home" @click="$router.push('/')"></span>
        <h1>推文类目编辑</h1>
      </div>
      <div style="height: 0.88rem;"></div>
    </div>
    <div class="type">
      <div class="list" v-if="list.length > 0">
        <div class="item" v-for="(item, index) in list" :key="index">
          <p class="name">{{ item.name }}</p>
          <div class="upOrDown" @click="toUp(index)">
            <img src="../../assets/images/mkf/toUp.png" />
          </div>
          <div class="upOrDown" @click="toDown(index)">
            <img src="../../assets/images/mkf/toDown.png" />
          </div>
          <p class="ope" @click="del(item.id)">删除</p>
          <p class="ope" @click="toEdit(item.name)">编辑</p>
        </div>
      </div>
      <button type="button" class="btn" @click="toEdit('')">
        新增推文分类
      </button>
    </div>
  </div>
</template>

<script>
export default {
  name: "",
  components: {},
  props: {},
  data: function() {
    return {
      list: [
        {
          id: 100,
          name: "推文类目名称1"
        },
        {
          id: 101,
          name: "推文类目名称2"
        },
        {
          id: 102,
          name: "类目名称3"
        }
      ]
    };
  },
  mounted: function() {},
  methods: {
    toUp(index) {
      if (index != 0) {
        this.list[index] = this.list.splice(index - 1, 1, this.list[index])[0];
      } else {
        this.$dialog.toast({ mes: "已置顶" });
      }
    },
    toDown(index) {
      if (index + 1 != this.list.length) {
        this.list[index] = this.list.splice(index + 1, 1, this.list[index])[0];
      } else {
        this.$dialog.toast({ mes: "已置底" });
      }
    },
    toEdit(v) {
      this.$router.push({
        path: "/com/articleTypeAdd?txt=" + v
      });
    },
    del(v) {
      console.log(v);
      this.$dialog.confirm({
        title: "是否确认删除该分类？",
        mes: "",
        opts: [
          {
            txt: "取消",
            color: "#999999",
            stay: false, //是否保留提示框
            callback: () => {
              //按钮回调函数
              console.log("取消");
            }
          },
          {
            txt: "确认",
            color: "#deaa8a",
            stay: false,
            callback: () => {
              console.log("确认");
              //
              // this.$dialog.alert({mes: '该类目下有推文</br>无法删除哦~'});
            }
          }
        ]
      });
    }
  }
};
</script>

<style scoped>
.type {
}
.type .list {
  padding-bottom: 1.5rem;
}
.type .list .item {
  width: 7.1rem;
  margin: 0 auto;
  border-bottom: 1px solid rgba(0, 0, 0, 0.3);
  padding: 0.4rem 0;
  display: flex;
  align-items: center;
}
.type .list .item .name {
  font-size: 0.32rem;
  line-height: 0.4rem;
  color: #ffffff;
  width: 3.6rem;
}
.type .list .item .upOrDown {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 0.68rem;
  height: 0.4rem;
}
.type .list .item .upOrDown img {
  display: block;
  width: 0.28rem;
  height: 0.14rem;
}
.type .list .item .ope {
  width: 0.9rem;
  text-align: right;
  margin: 0 0.07rem 0 0.1rem;
  font-size: 0.24rem;
  color: #999999;
}

.type .btn {
  display: block;
  width: 100%;
  height: 0.98rem;
  background-color: #deaa8a;
  font-size: 0.32rem;
  color: #2a2631;
  position: fixed;
  left: 0;
  bottom: 0;
  z-index: 10;
}
</style>
